
/**
 * HittableList
 * @version 1.0
 * @since 1.0
 * <p>
 * Created by Murphy at 2021/7/9 16:44
 **/
#include "HittableList.hpp"
namespace Stitches
{

bool HittableList::hit(const Ray &r, double tmin, double tmax, HitRecord &rec) const
{
    HitRecord temp_rec;
    bool hit_anything = false;
    double closest_so_far = tmax;
    for (const auto &object : objects)
    {
        if (object->hit(r, tmin, closest_so_far, temp_rec))
        {
            hit_anything = true;
            closest_so_far = temp_rec.t;
            rec = temp_rec;
        }
    }
    return hit_anything;
}

}